//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

public class demo_852 {
    public demo_852() {
    }

    public int peakIndexInMountainArray(int[] arr) {
        for(int i = 0; i < arr.length; ++i) {
            if (arr[i] > arr[i + 1]) {
                return i;
            }
        }

        return 0;
    }

    public int peakIndexInMountainArray2(int[] arr) {
        int left = 0;
        int right = arr.length - 2;

        while(left + 1 < right) {
            int mid = left + (right - left) / 2;
            if (arr[mid] > arr[mid + 1]) {
                right = mid;
            } else {
                left = mid;
            }
        }

        return right;
    }
}
